package book;

import java.time.LocalDate;

public class Book implements Comparable<Book> {
      private int bookID;   //书id
      private String title;   //书名
      private String author;  //作者
      private String category;  //类别
      public int pubilishYear;  //出版年份
      private boolean isBorrowed;  //借阅状态
      private int borrowCount;   //借阅次数
      private LocalDate shelfDate;   //上架时间

    public int getBookID() {
        return bookID;
    }

    public void setBookID(int bookID) {
        this.bookID = bookID;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public int getPubilishYear() {
        return pubilishYear;
    }

    public void setPubilishYear(int pubilishYear) {
        this.pubilishYear = pubilishYear;
    }


    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }

    public int getBorrowCount() {
        return borrowCount;
    }

    public void setBorrowCount(int borrowCount) {
        this.borrowCount = borrowCount;
    }

    public LocalDate getShelfDate() {
        return shelfDate;
    }

    public void setShelfDate(LocalDate shelfDate) {
        this.shelfDate = shelfDate;
    }
    public boolean isBorrowed() {
        return isBorrowed;
    }
    public void incrementBorrowCount(){
        this.borrowCount++;
    }
    public void decreaseBorrowCount(){
        this.borrowCount--;
    }
    @Override
    public int compareTo(Book o) {
        return o.borrowCount-this.borrowCount;
    }

    @Override
    public String toString() {
        return "Book{" +
                "bookID=" + bookID +
                ", title='" + title + '\'' +
                ", author='" + author + '\'' +
                ", category='" + category + '\'' +
                ", pubilishYear=" + pubilishYear +
                ", isBorrowed=" + isBorrowed +
                ", borrowCount=" + borrowCount +
                ", shelfDate=" + shelfDate +
                '}';
    }
    public String toJSON(){

    }
}
